package com.huluobo.jetpackkotlindemo.viewbinding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding

/**
 * Created by lc on 2022/12/9.
 * 1.调用生成的绑定类中的inflate()方法来获取绑定类的实例
 * 2.通过调用绑定类的getRoot()方法获取根视图
 * 3.将根视图(root)传递到setContentView()中,与当前activity进行绑定
 */
abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
    lateinit var mViewBinding: T
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mViewBinding = getViewBinding()
        setContentView(mViewBinding.root)
    }

    abstract fun getViewBinding(): T
}